﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;
using System.Diagnostics;

namespace Httlgd.DataCenter.Services.Core.Logging
{
    public class LogManager
    {
        private static LogWriter defaultWriter = EnterpriseLibraryContainer.Current.GetInstance<LogWriter>();

        public static void WriteGeneralLog(string message, string title)
        {
            Dictionary<string, object> exProperties = new Dictionary<string, object>();

            WriteLog("General", message, title, 1, TraceEventType.Information, exProperties);
        }

        public static void WriteSystemErrorLog(string message, string title, int priority, TraceEventType severity)
        {
            Dictionary<string, object> exProperties = new Dictionary<string, object>();
            WriteLog("Logging Errors & Warnings", message, title, priority, severity, exProperties);
        }

        private static void WriteLog(string category, string message, string title, int priority, TraceEventType severity, Dictionary<string, object> exProperties)
        {
            LogEntry logEntry = new LogEntry(message, category, priority, 1, severity, title, exProperties);
            defaultWriter.Write(logEntry);
        }
    }
}
